home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 4 / MacAddict_004_1996_12.iso / Sponsors / Bungie / Abuse Demo / lisp / duong.lsp < prev    next >
Lisp/Scheme  |  1996-08-01  |  11KB  |  420 lines

  1. ;; Copyright 1995 Crack dot Com,  All Rights reserved
  2. ;; See licensing information for more details on usage rights
  3.  
  4. /*  written in C
  5.  
  6. (defun tp2_ai ()
  7.   (if (> (total_objects) 0)
  8.       (select (aistate)
  9.           (0 ;; wait for player to activate
  10.            (if (and (touching_bg) (eq (total_objects) 1))
  11.            (progn
  12.              (if (with_object (bg) (pressing_action_key))
  13.              (progn
  14.                (link_object (bg))
  15.                (set_state running)
  16.                (play_sound TELEPORTER_SND 127 (x) (y))
  17.                (set_aistate 1))))))
  18.           (1 ;; wait for animation
  19.            (if (next_picture)
  20.            (let ((x (x))
  21.              (y (- (y) 16))
  22.              (fade (if (< (current_frame) 16) (current_frame) 15)))
  23.              (with_object (get_object 1) 
  24.                   (progn
  25.                     (set_x x) 
  26.                     (set_y y) 
  27.                     (user_fun SET_FADE_COUNT fade)
  28.                     (setq is_teleporting 1)
  29.                     )))
  30.                   
  31.          (let ((x (with_object (get_object 0) (x)))
  32.                (y (with_object (get_object 0) (- (y) 16))))           
  33.            (with_object (get_object 1)
  34.                 (progn 
  35.                   (set_x x)
  36.                   (set_y y)
  37.                   (setq is_teleporting 0)
  38.                   (user_fun SET_FADE_COUNT 0)
  39.                   ))
  40.            (remove_object (get_object 1))
  41.            (set_aistate 0))))))
  42.   T)
  43. */       
  44.  
  45. (defun mine_ai ()
  46.   (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
  47.       (select (aistate)
  48.           (0 (if (touching_bg)
  49.              (progn (set_state running)
  50.                 (if (eq (xvel) 1)
  51.                 (progn
  52.                   (with_object (bg)
  53.                            (make_view_solid (find_rgb 250 10 10)))
  54.                   (hurt_radius (x) (y) 40 35 nil 20))
  55.                   (hurt_radius (x) (y) 40 25 nil 20))
  56.                 (go_state 1))
  57.            (next_picture))
  58.            T)
  59.           (1 (next_picture)))
  60.     T))
  61.  
  62.  
  63.  
  64.  
  65. (def_char CONC
  66.   (funs (ai_fun  mine_ai))
  67.   (fields  ("xvel" conc_flash))
  68.   (states "art/chars/mine.spe"
  69.       (running   (seq "mine" 1 8))
  70.       (stopped    '("mine0001.pcx" "mine_off"))))
  71.  
  72.  
  73.  
  74. (defun air_mine_ai ()
  75.   (if (or (eq (total_objects) 0)                                 ;; turned on?
  76.       (not (eq (with_object (get_object 0) (aistate)) 0)))
  77.  
  78.       (if (touching_bg)
  79.       (progn
  80.         (if (eq (xvel) 1)
  81.         (with_object (bg) (make_view_solid (find_rgb 250 10 10))))
  82.         (do_explo 40 25)
  83.         nil)
  84.     (progn (next_picture)
  85.            T))
  86.     T))
  87.  
  88. (def_char CONC_AIR
  89.   (funs (ai_fun  air_mine_ai))
  90.   (fields  ("xvel" conc_flash))
  91.   (states "art/chars/mine.spe"
  92.       (stopped   (seq "amin" 1 2))))
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99. (defun bomb_cons ()
  100.   (setq blink_time 14))
  101.  
  102. (defun bomb_ai ()
  103.   (select (aistate)
  104.       (0 ;; wait for a signal if connected, or wait for player touch
  105.        (if (activated)
  106.            (go_state 1)
  107.          T))
  108.  
  109.       (1 ;; count down blink time until zero then blow up
  110.        (if (< blink_time 1)
  111.            (go_state 2)
  112.          (progn
  113.            (if (or (< blink_time 10)
  114.                (and (< blink_time 18) (eq (mod blink_time 2) 0))
  115.                (and (< blink_time 30) (eq (mod blink_time 3) 0))
  116.                (and (< blink_time 50) (eq (mod blink_time 4) 0)))
  117.            (progn
  118.              (play_sound TICK_SND 127 (x) (y))
  119.              (next_picture)))
  120.            (setq blink_time (- blink_time 1))
  121.            T)))
  122.  
  123.       (2 ;; blow up
  124.        (let ((oldy (y)))
  125.          (set_y (- (y) (/ (picture_height) 2)))
  126.          (do_explo 40 (get_ability jump_yvel))
  127.          (if (> (get_ability jump_yvel) 100)
  128.          (add_object EXPLODE1 (+ (x) (random 10)) (+ (+ (random 10) (y)) -20)     0))
  129.          (set_y oldy))
  130.        nil)))
  131.   
  132.       
  133.                  
  134. (def_char BOMB
  135.   (funs (ai_fun      bomb_ai)
  136.     (constructor bomb_cons))
  137.   (abilities (jump_yvel 30))
  138.   (range 150 150)
  139.   (vars blink_time)
  140.   (fields ("blink_time" bomb_blink))
  141.   (states "art/chars/mine.spe"
  142.       (stopped '("abomb0001.pcx" "abomb0002.pcx"))))
  143.  
  144. (def_char BIG_BOMB
  145.   (funs (ai_fun      bomb_ai)
  146.     (constructor bomb_cons))
  147.   (abilities (jump_yvel 400))
  148.   (range 150 150)
  149.   (vars blink_time)
  150.   (fields ("blink_time" bomb_blink))
  151.   (states "art/chars/mine.spe"
  152.       (stopped '("abomb0001.pcx+" "abomb0002.pcx+"))))
  153.       
  154.  
  155.  
  156.  
  157. (defun block_ai ()
  158.   (if (<= (hp) 0)
  159.       (if (eq (state) dieing)
  160.       (next_picture)
  161.     (progn
  162.       (play_sound CRUMBLE_SND 127 (x) (y))
  163.       (set_state dieing)
  164.       T))
  165.     T))
  166.  
  167. (def_char BLOCK
  168.                     ;block has only 1 frame now will have block blowing up
  169.   (funs (ai_fun  block_ai))
  170.   (flags (can_block T)
  171.      (hurtable  T))
  172.   (abilities (start_hp 30))
  173.   (states "art/chars/block.spe"
  174.       (stopped       "block.pcx")
  175.       (dieing        (seq "bexplo" 1 7))))
  176.  
  177.  
  178. (defun trap_door_ai ()
  179.   (if (> (total_objects) 0)
  180.       (select (aistate)
  181.           (0 ;; wait for switch to go off
  182.            (if (not (eq (with_object (get_object 0) (aistate)) 0))
  183.            (progn 
  184.              (set_state running)
  185.              (go_state 1))))
  186.           (1 ;; wait for animation
  187.            (if (next_picture) T
  188.          (progn
  189.            (set_state blocking)
  190.            (set_aistate 2))))
  191.           (2 ;; just stay here 
  192.            T)))
  193. T)
  194.       
  195.  
  196. (defun strap_door_ai ()
  197.   (general_sdoor_ai nil))
  198.  
  199.  
  200. (def_char TRAP_DOOR2
  201.   (funs (ai_fun strap_door_ai))
  202.   (flags (can_block T))
  203.   (abilities (start_hp 30))
  204.   (states "art/chars/tdoor.spe"
  205.       (stopped        "tdor0001.pcx")
  206.       (running        (seq "tdor" 1 7))
  207.       (walking        (seq "tdor" 7 1))
  208.       (blocking       "tdor0007.pcx")))
  209.  
  210.  
  211. (def_char TRAP_DOOR3
  212.   (funs (ai_fun strap_door_ai))
  213.   (flags (can_block T))
  214.   (abilities (start_hp 30))
  215.   (states "art/chars/tdoor.spe"
  216.           (stopped        "cdor0001.pcx")
  217.           (running        (seq "cdor" 1 7))
  218.           (walking        (seq "cdor" 7 1))
  219.           (blocking       "cdor0007.pcx")))
  220.  
  221. (defun lightin_ai ()
  222.   (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
  223.       (select (aistate)
  224.           (0  ;; delay
  225.            (if (< (state_time) (* (aitype) 2)) (set_state stopped)
  226.          (progn
  227.                     ;         (hurt_radius (x) (y) 40 30 nil 30)
  228.            (set_state running)
  229.            (play_sound ELECTRIC_SND 127 (x) (y))
  230.            (go_state 1))))
  231.           (1  ;; next picture
  232.            (if (next_picture) T
  233.          (set_aistate 0)))))
  234. T)
  235.  
  236. (def_char LIGHTIN
  237.   (funs (ai_fun lightin_ai))
  238.   (flags (can_block T))
  239.   (fields  ("aitype" lightin_speed))
  240.   (states "art/chars/lightin.spe"
  241.       (running   (seq "lite" 1 9))
  242.       (stopped    "lite0001.pcx")))
  243.       
  244.  
  245.  
  246. (defun lava_ai ()
  247.   (if (and (touching_bg) (eq (mod (state_time) 20) 0))
  248.       (do_damage 6 (bg)))
  249.  
  250.   (select (aistate)
  251.       (0 (if (eq (random 100) 0)
  252.          (progn
  253.            (play_sound LAVA_SND 64 (x) (y))
  254.            (set_aistate 1)))
  255.          (next_picture))
  256.       (1 (next_picture)
  257.          (if (eq (state_time) 5)
  258.          (progn
  259.            (hurt_radius (x) (y) 20 20 nil 10)
  260.            (set_aistate 0)))))
  261.   T)
  262.  
  263.  
  264. (def_char LAVA
  265.   (funs (ai_fun lava_ai))
  266.   (states  "art/chars/lava.spe"
  267.        (stopped (seq "lava" 1 15))))
  268.  
  269.                
  270.  
  271. (def_char TELE2
  272.   (funs  (ai_fun tp2_ai))
  273.   (flags (can_block  T))
  274.   (states "art/chars/teleport.spe"
  275.       (stopped "close")
  276.       (running (seq "elec" 1 15))))
  277.      
  278.  
  279. (defun bolder_ai ()
  280.   (if (or (eq (total_objects) 0) (not (eq (with_object (get_object 0) (aistate)) 0)))
  281.       (if (eq (hp) 0)
  282.       (progn
  283.         (play_sound P_EXPLODE_SND 127 (x) (y))
  284.         (add_object EXPLODE1 (+ (x) (random 5)) (+ (y) (random 5)) 0)
  285.         (add_object EXPLODE1 (+ (x) (random 5)) (+ (y) (random 5)) 2)
  286.         (add_object EXPLODE1 (- (x) (random 5)) (- (y) (random 5)) 1)
  287.         (add_object EXPLODE1 (- (x) (random 5)) (- (y) (random 5)) 2)
  288.         (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel -4) (set_yvel -8)))
  289.         (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel 4) (set_yvel -9)))
  290.         (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel 2) (set_yvel -5)))
  291.         (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel -3) (set_yvel -5)))
  292.         (with_object (add_object SMALL_BOLDER (x) (y)) (progn (set_xvel -1) (set_yvel 2)))
  293.         (add_object EXP_LIGHT (x) (y) 100)
  294.         nil)
  295.     (progn
  296.       (next_picture)
  297.       (set_yvel (+ (yvel) 1))      
  298.       (let ((old_yv  (yvel))
  299.         (old_xv  (xvel))
  300.         (old_x   (x))
  301.         (old_y   (y))
  302.         (status (float_tick)))
  303.  
  304.         (let ((new_x (x))
  305.           (new_y (y))
  306.           (set_x old_x)
  307.           (set_y old_y))
  308.           (platform_push (- new_x (x)) (- new_y (y)))
  309.           (set_x new_x)
  310.           (set_y new_y))
  311.         (hurt_radius (x) (y) 19 30 (me) 15)
  312.         (if (not (eq status T));; T means we did not hit anything    
  313.         (let ((block_flags (car status)))
  314.           (if (or (blocked_up block_flags) (blocked_down block_flags));; bounce up/down
  315.               (progn
  316.             (if (> (abs old_yv) 3)
  317.                 (play_sound SBALL_SND 127 (x) (y)))
  318.             (set_xvel old_xv)
  319.             (if (> old_yv 1)
  320.                 (set_yvel (- 2 old_yv))
  321.               (set_yvel (- 0 old_yv))))
  322.             (if (or (blocked_left block_flags) (blocked_right block_flags));; bounce left/right
  323.             (progn
  324.               (set_yvel old_yv)
  325.               (set_xvel (- 0 old_xv))))))))
  326.       T))
  327.     T))
  328.   
  329.  
  330. (defun bolder_cons ()
  331.   (set_xvel -4)
  332.   (set_yvel 0))
  333.  
  334.  
  335. (defun bold_dam (amount from hitx hity push_xvel push_yvel) 
  336.   (add_object EXPLODE3 (+ (x) (- 10 (random 20))) (- (y) (random 30)) 0)
  337.   (damage_fun amount from hitx hity (/ push_xvel 10) (/ push_yvel 2)))
  338.  
  339. (def_char BOLDER
  340.   (funs  (ai_fun bolder_ai)
  341.      (damage_fun bold_dam)
  342.      (constructor bolder_cons))
  343.   (flags (can_block  T)
  344.      (add_front  T)
  345.      (hurtable   T))
  346.   (range 200 200)
  347.   (abilities (start_hp 40))
  348.   (fields ("xvel" ai_xvel)      
  349.       ("yvel" ai_yvel)
  350.       ("hp"   ai_health)
  351.       )
  352.   (states "art/bold.spe"
  353.       (stopped '("bold0001.pcx" "bold0001.pcx" "bold0001.pcx" 
  354.             "bold0002.pcx" "bold0002.pcx" "bold0002.pcx"
  355.             "bold0003.pcx" "bold0003.pcx" "bold0003.pcx"
  356.             "bold0004.pcx" "bold0004.pcx" "bold0004.pcx"))))
  357.  
  358. (defun bounce_move (left_stub right_stub up_stub down_stub nothing_stub)
  359.   (let ((old_yv  (yvel))
  360.     (old_xv  (xvel))
  361.     (status (float_tick)))
  362.     (if (not (eq status T)) ;; T means we did not hit anything    
  363.     (let ((block_flags (car status)))            
  364.       (if (blocked_up block_flags) ;; bounce up/down
  365.           (progn
  366.         (set_xvel old_xv)
  367.         (if (> old_yv 1)
  368.             (set_yvel (- 2 old_yv))
  369.           (set_yvel (- 0 old_yv)))
  370.         (eval up_stub))
  371.         (if (blocked_down block_flags)
  372.         (progn
  373.           (set_xvel old_xv)
  374.           (if (> old_yv 1)
  375.               (set_yvel (- 2 old_yv))
  376.             (set_yvel (- 0 old_yv)))
  377.           (eval down_stub))
  378.           (if (blocked_left block_flags)
  379.           (progn
  380.             (set_yvel old_yv)
  381.             (set_xvel (- 0 old_xv))
  382.             (eval left_stub))
  383.         (if (blocked_right block_flags)
  384.             (progn
  385.               (set_yvel old_yv)
  386.               (set_xvel (- 0 old_xv))
  387.               (eval right_stub)))))))
  388.       (eval nothing_stub))))
  389.           
  390.  
  391.  
  392. (defun small_rock_ai ()
  393.   (next_picture)
  394.   (set_yvel (+ (yvel) 1))
  395.   (bounce_move T T T            
  396.            '(progn (add_object EXPLODE1 (+ (x) (random 10)) (- (+ (random 5) (y)) 10)     0)               
  397.          (add_object EXPLODE1 (- (x) (random 10)) (- (- (y) (random 5)) 10) 2)
  398.          (play_sound P_EXPLODE_SND 127 (x) (y))
  399.          (hurt_radius (x) (y) 40 15 (if (> (total_objects) 0)
  400.                         (get_object 0)
  401.                           nil) 20)
  402.          nil) T))
  403.   
  404.  
  405. (def_char SMALL_BOLDER
  406.   (funs  (ai_fun small_rock_ai))
  407.  
  408.   (flags (add_front  T)
  409.      (unlistable T))
  410.     
  411.   (states "art/bold.spe"
  412.       (stopped "bsmall")))
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.